import switchItemComp from './switchItem.vue'
import switchItemDetail from './switchItemDetail.vue'
import Vue from "vue";

var switchItem = {    
    type:'switchItem',//item类型
    checked:false,
    icon:'el-icon-sunset',//item图标
    txt:'开关', //item名称
    methods:{
        install:function(item,page,event){//选中图标页面点击事件,命名规则`${item.type}Install`            
            return Object.assign({
                type:'switchItem',
                width:100,
                height:40,
                state:0,
                stateIcon:['/static/switchItem/s0.svg','/static/switchItem/s1.svg'],
                lock:false
            }, item);
        },
        render:function(refs,item){        
            var comp=Vue.extend(switchItemComp);
            var instance=new comp({
                propsData:{
                    attr:item
                }
            });
            instance.$mount();
            refs.appendChild(instance.$el);
        },
        detailRender:function(refs,item){//加载详细信息控件,命名规则`${item.type}DetailRender`       
            var comp=Vue.extend(switchItemDetail);
            var instance=new comp({
                propsData:{
                    attr:item
                }
            });
            instance.$mount();
            //console.log('switchItemRenderDetial to refs',refs,instance);
            refs.appendChild(instance.$el);
        }
    }
}

export default switchItem;